package com.springboot.auth.authorization.rest;

import javax.servlet.http.HttpServletRequest;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import lombok.extern.slf4j.Slf4j;


/**
 * 处理登录控制器
 * @author yuancheng
 *
 */
@Slf4j
@RestController
public class LoginController {

	@GetMapping("/auth/login")
    public ModelAndView loginPage(Model model){  
        model.addAttribute("loginProcessUrl","/auth/authorize");
        return new ModelAndView("base-login", "userModel", model);
    }
	
    @GetMapping("/login-error")
    public ModelAndView loginError(HttpServletRequest request, Model model) {
        model.addAttribute("loginError", true);
        model.addAttribute("errorMsg", "登陆失败，账号或者密码错误！");
        return new ModelAndView("newlogin", "userModel", model);
    }
    
    
}
